home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -seriously_amiga- / programming / other / cyberxxxsrc / decoder / txt / fastc2p.asm < prev    next >
Assembly Source File  |  1999-02-08  |  7KB  |  343 lines

  1. ;prog:phxass/gigaphxass txt/FastC2P.asm to obj/FastC2P.o noexe
  2.  
  3.     SECTION FastC2P,CODE
  4.  
  5.     XDEF    _FastC2P4
  6.     XDEF    _FastC2P8
  7.  
  8. *-----------------------------------------------------------------------*
  9. ;
  10. ; Chunky2Planar Conversion Routine
  11.  
  12. bm_BytesPerRow  equ 0
  13. bm_Rows         equ 2
  14. bm_Flags        equ 4
  15. bm_Depth        equ 5
  16. bm_Pad          equ 6
  17. bm_Planes       equ 8
  18.  
  19. _FastC2P4:
  20.         movem.l a2-a6/d2-d7,-(sp)
  21.         move.l  #$00ff00ff,a3
  22.         move.l  #$0f0f0f0f,a4
  23.         move.l  #$33333333,a5
  24.         move.l  #$55555555,a6
  25.  
  26.         moveq   #0,d0
  27.         move.w  bm_BytesPerRow(a1),d0
  28.  
  29.         moveq   #1,d2
  30.         lsr.l   d2,d1                   ; Modulo halbieren, nötig für 4 Bit
  31.  
  32.         sub.w   d0,d1                   ; Modulo berechnen
  33.         move.w  d1,-(sp)
  34.  
  35.         moveq   #0,d1
  36.         move.b  bm_Depth(a1),d1
  37.         add.w   d1,d1
  38.         divu    d1,d0
  39.         add.w   d0,d0
  40.         move.w  d0,a2
  41.         move.w  bm_Rows(a1),d0
  42.         subq.w  #1,d0
  43.       ; add.w   d1,d1
  44.       ; jmp     FastC2PTab-3*4(pc,d1.w)
  45.  
  46. FastC2P4:
  47.         move.l  bm_Planes(a1),a1
  48. .loop1
  49.         move.w  a2,d1
  50.         lsr.w   #1,d1
  51.         subq.w  #1,d1
  52. .loop2
  53.         movem.l (a0)+,d4-d7
  54.  
  55.         move.l  a3,d2
  56.         move.l  a3,d3
  57.         and.l   d4,d2
  58.         and.l   d6,d3
  59.         eor.l   d2,d4
  60.         eor.l   d3,d6
  61.         lsl.l   #8,d2
  62.         lsr.l   #8,d6
  63.         or.l    d3,d2
  64.         or.l    d6,d4
  65.  
  66.         move.l  a3,d3
  67.         move.l  a3,d6
  68.         and.l   d5,d3
  69.         and.l   d7,d6
  70.         eor.l   d3,d5
  71.         eor.l   d6,d7
  72.         lsl.l   #8,d3
  73.         lsr.l   #8,d7
  74.         or.l    d6,d3
  75.         or.l    d7,d5
  76.  
  77.         move.l  a4,d6
  78.         move.l  a4,d7
  79.         and.l   d4,d6
  80.         and.l   d5,d7
  81.         eor.l   d6,d4
  82.         eor.l   d7,d5
  83.         lsl.l   #4,d6
  84.         lsr.l   #4,d5
  85.         or.l    d7,d6
  86.         or.l    d5,d4
  87.  
  88.         move.l  a4,d7
  89.         move.l  a4,d5
  90.         and.l   d2,d7
  91.         and.l   d3,d5
  92.         eor.l   d7,d2
  93.         eor.l   d5,d3
  94.         lsl.l   #4,d7
  95.         lsr.l   #4,d3
  96.         or.l    d5,d7
  97.         or.l    d3,d2
  98.  
  99.         swap    d6
  100.         move.w  d6,d3
  101.         move.w  d4,d6
  102.         move.w  d3,d4
  103.         swap    d6
  104.  
  105.         swap    d7
  106.         move.w  d7,d3
  107.         move.w  d2,d7
  108.         move.w  d3,d2
  109.         swap    d7
  110.  
  111.         move.l  a5,d3
  112.         move.l  a5,d5
  113.         and.l   d4,d3
  114.         and.l   d6,d5
  115.         eor.l   d3,d4
  116.         eor.l   d5,d6
  117.         lsl.l   #2,d3
  118.         lsr.l   #2,d6
  119.         or.l    d5,d3
  120.         or.l    d6,d4
  121.  
  122.         move.l  a5,d5
  123.         move.l  a5,d6
  124.         and.l   d2,d5
  125.         and.l   d7,d6
  126.         eor.l   d5,d2
  127.         eor.l   d6,d7
  128.         lsl.l   #2,d5
  129.         lsr.l   #2,d7
  130.         or.l    d6,d5
  131.         or.l    d7,d2
  132.  
  133.         move.l  a6,d6
  134.         move.l  a6,d7
  135.         and.l   d4,d6
  136.         and.l   d2,d7
  137.         eor.l   d6,d4
  138.         eor.l   d7,d2
  139.         lsr.l   #1,d2
  140.         add.l   d6,d6
  141.         or.l    d2,d4
  142.         or.l    d7,d6
  143.  
  144.         move.l  a6,d7
  145.         move.l  a6,d2
  146.         and.l   d3,d7
  147.         and.l   d5,d2
  148.         eor.l   d7,d3
  149.         eor.l   d2,d5
  150.         lsr.l   #1,d5
  151.         add.l   d7,d7
  152.         or.l    d5,d3
  153.         or.l    d2,d7
  154.  
  155.         move.w  d7,(a1)+                ; bit 0
  156.         move.w  a2,d2
  157.         move.w  d3,-2(a1,d2.w)          ; bit 1
  158.         add.w   a2,d2
  159.         move.w  d6,-2(a1,d2.w)          ; bit 2
  160.         add.w   a2,d2
  161.         move.w  d4,-2(a1,d2.w)          ; bit 3
  162.  
  163.         dbra    d1,.loop2
  164.  
  165.         adda.w  d2,a1
  166.  
  167.         add.w   (sp),a0                 ; Modulo aufaddieren
  168.         dbra    d0,.loop1
  169.  
  170.         add.w   #2,sp                   ; Modulo vom Stack nehmen
  171.         movem.l (sp)+,a2-a6/d2-d7
  172.         rts
  173.  
  174.  
  175.  
  176. _FastC2P8:
  177.         movem.l a2-a6/d2-d7,-(sp)
  178.         move.l  #$00ff00ff,a3
  179.         move.l  #$0f0f0f0f,a4
  180.         move.l  #$33333333,a5
  181.         move.l  #$55555555,a6
  182.  
  183.         moveq   #0,d0
  184.         move.w  bm_BytesPerRow(a1),d0
  185.  
  186.         sub.w   d0,d1                   ; Modulo berechnen
  187.         move.w  d1,-(sp)
  188.  
  189.         moveq   #0,d1
  190.         move.b  bm_Depth(a1),d1
  191.         add.w   d1,d1
  192.         divu    d1,d0
  193.         add.w   d0,d0
  194.         move.w  d0,a2
  195.         move.w  bm_Rows(a1),d0
  196.         subq.w  #1,d0
  197.       ; add.w   d1,d1
  198.       ; jmp     FastC2PTab-3*4(pc,d1.w)
  199.  
  200. FastC2P8:
  201.         move.l  bm_Planes(a1),a1
  202. .loop1
  203.         move.w  a2,d1
  204.         moveq   #1,d2
  205.         lsr.w   d2,d1
  206.         sub.w   d2,d1
  207. .loop2
  208.         movem.l (a0)+,d4-d7
  209.  
  210.         move.l  a3,d2
  211.         move.l  a3,d3
  212.         and.l   d4,d2
  213.         and.l   d6,d3
  214.         eor.l   d2,d4
  215.         eor.l   d3,d6
  216.         lsl.l   #8,d2
  217.         lsr.l   #8,d6
  218.         or.l    d3,d2
  219.         or.l    d6,d4
  220.  
  221.         move.l  a3,d3
  222.         move.l  a3,d6
  223.         and.l   d5,d3
  224.         and.l   d7,d6
  225.         eor.l   d3,d5
  226.         eor.l   d6,d7
  227.         lsl.l   #8,d3
  228.         lsr.l   #8,d7
  229.         or.l    d6,d3
  230.         or.l    d7,d5
  231.  
  232.         move.l  a4,d6
  233.         move.l  a4,d7
  234.         and.l   d4,d6
  235.         and.l   d5,d7
  236.         eor.l   d6,d4
  237.         eor.l   d7,d5
  238.         lsl.l   #4,d6
  239.         lsr.l   #4,d5
  240.         or.l    d7,d6
  241.         or.l    d5,d4
  242.  
  243.         move.l  a4,d7
  244.         move.l  a4,d5
  245.         and.l   d2,d7
  246.         and.l   d3,d5
  247.         eor.l   d7,d2
  248.         eor.l   d5,d3
  249.         lsl.l   #4,d7
  250.         lsr.l   #4,d3
  251.         or.l    d5,d7
  252.         or.l    d3,d2
  253.  
  254.         swap    d6
  255.         move.w  d6,d3
  256.         move.w  d4,d6
  257.         move.w  d3,d4
  258.         swap    d6
  259.  
  260.         swap    d7
  261.         move.w  d7,d3
  262.         move.w  d2,d7
  263.         move.w  d3,d2
  264.         swap    d7
  265.  
  266.         move.l  a5,d3
  267.         move.l  a5,d5
  268.         and.l   d4,d3
  269.         and.l   d6,d5
  270.         eor.l   d3,d4
  271.         eor.l   d5,d6
  272.         lsl.l   #2,d3
  273.         lsr.l   #2,d6
  274.         or.l    d5,d3
  275.         or.l    d6,d4
  276.  
  277.         move.l  a5,d5
  278.         move.l  a5,d6
  279.         and.l   d2,d5
  280.         and.l   d7,d6
  281.         eor.l   d5,d2
  282.         eor.l   d6,d7
  283.         lsl.l   #2,d5
  284.         lsr.l   #2,d7
  285.         or.l    d6,d5
  286.         or.l    d7,d2
  287.  
  288.         move.l  a6,d6
  289.         move.l  a6,d7
  290.         and.l   d4,d6
  291.         and.l   d2,d7
  292.         eor.l   d6,d4
  293.         eor.l   d7,d2
  294.         lsr.l   #1,d2
  295.         add.l   d6,d6
  296.         or.l    d2,d4
  297.         or.l    d7,d6
  298.  
  299.         move.l  a6,d7
  300.         move.l  a6,d2
  301.         and.l   d3,d7
  302.         and.l   d5,d2
  303.         eor.l   d7,d3
  304.         eor.l   d2,d5
  305.         lsr.l   #1,d5
  306.         add.l   d7,d7
  307.         or.l    d5,d3
  308.         or.l    d2,d7
  309.  
  310.         move.w  d7,(a1)+                ; bit 0
  311.         move.w  a2,d2
  312.         move.w  d3,-2(a1,d2.w)          ; bit 1
  313.         add.w   a2,d2
  314.         move.w  d6,-2(a1,d2.w)          ; bit 2
  315.         add.w   a2,d2
  316.         move.w  d4,-2(a1,d2.w)          ; bit 3
  317.         swap    d7
  318.         add.w   a2,d2
  319.         move.w  d7,-2(a1,d2.w)          ; bit 4
  320.         swap    d3
  321.         add.w   a2,d2
  322.         move.w  d3,-2(a1,d2.w)          ; bit 5
  323.         swap    d6
  324.         add.w   a2,d2
  325.         move.w  d6,-2(a1,d2.w)          ; bit 6
  326.         swap    d4
  327.         add.w   a2,d2
  328.         move.w  d4,-2(a1,d2.w)          ; bit 7
  329.  
  330.         dbra    d1,.loop2
  331.  
  332.         adda.w  d2,a1
  333.  
  334.         add.w   (sp),a0                 ; Modulo aufaddieren
  335.         dbra    d0,.loop1
  336.  
  337.         add.w   #2,sp                   ; Modulo vom Stack nehmen
  338.         movem.l (sp)+,a2-a6/d2-d7
  339.         rts
  340.  
  341.         END
  342.  
  343.